<#include "../global/header.html">
<div class="aw-container-wrap">
<div class="aw-container aw-wecenter aw-user" >
<div class="aw-user-setting">
<div class="tab-content clearfix">

<!--搜索-->
<div class="aw-mod">
<div class="aw-mod-head">
    <h4>搜索</h4>
</div>
<form id="setting_form" method="get" action="search">
<#if  error = 0>
    <div class="alert alert-error" >
        <button type="button" class="close" data-dismiss="alert">×</button>
        <span >${errormsg!}</span></div>
</#if>
<div class="aw-mod-body aw-user-setting-layout aw-user-setting-base row">
<div class="col-md-6">
<div class="dropdown" style="float: right;margin-right: 185px">
    <button class="btn btn-default dropdown-toggle btn-info" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
        选择搜索模板
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
        <!--<li role="presentation"><a role="menuitem"  tabindex="-1" onclick="insertMo();">新增</a></li>-->
        <!--<li role="presentation"><a role="menuitem"  tabindex="-1" onclick="updateMo();">修改</a></li>-->
        <!--<li role="presentation"><a role="menuitem" tabindex="-1"   onclick="dele();">删除</a></li>-->
        <li role="presentation"><a role="menuitem" tabindex="-1" onclick="moban(0)" id="0">无</a></li>
        <#list modul as x>
            <li role="presentation" ><a role="menuitem" tabindex="-1" onclick="caoz(${x.id})">${x.name}</a></li>
        </#list>
    </ul>
    <!--<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>-->

    <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="pand" aria-hidden="true" style="margin-top: 200px">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4  class="modal-title">
                        <input type="hidden" name="hiden" id="hiden" value="${hiden!}">
                         <button type="button" class="btn btn-primary" data-toggle="modal" onclick="moban(-1)" data-target=".bs-example-modal-sm">选用</button>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="button" class="btn btn-danger" data-toggle="modal "onclick="dele();" data-target=".bs-example-modal-sm">删除</button>
                        </h4>
                   </div>
            </div>
        </div>
    </div>
</div>
<dl>
    <dt>&nbsp;</dt>
    <dd>
        <!--<select id="model" onchange="moban(0);" name="model">-->
            <!--<option value="0">无</option>-->
            <!--<#list modul as x>-->
                <!--<option value="${x.id}">${x.name}</option>-->
            <!--</#list>-->

        <!--</select>&nbsp;&nbsp;&nbsp;-->
        <!--<input type="button" value="操作" onclick="" data-toggle="modal" data-target="#myModal" class="btn btn-sm btn-info">-->



        <!-- Modal -->
        <!--<form id="setting_form_d" method="post" action="search/modul_add">-->
        <!--<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">-->
            <!--<div class="modal-dialog">-->
                <!--<div class="modal-content">-->
                    <!--<div class="modal-header">-->
                        <!--<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>-->
                        <!--<h4  class="modal-title" id="myModalLabel">-->
                            <!--<div style="margin-top: 5px">-->

                                <!--<dl>-->
                                    <!--<dt>搜索模板:</dt>-->
                                    <!--<dd>-->
                                        <!--<select onchange="moban(2);" id="model1">-->
                                            <!--<option value="0">无</option>-->
                                            <!--<#list modul as x>-->
                                                <!--<option value="${x.id}">${x.name}</option>-->
                                            <!--</#list>-->
                                        <!--</select>-->
                                    <!--</dd>-->
                                <!--</dl>-->
                            <!--</div>-->
                        <!--</h4>-->
                    <!--</div>-->
                    <!--<div class="modal-body">-->
                        <!--<input type="hidden" id="hiddenId">-->
                        <!--<dl>-->
                            <!--<dt>模板名称:</dt>-->
                            <!--<dd> <input type="text" name="name_d" id="name_d"  class="form-control" placeholder="模板名称"-->
                                    <!--/></dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>关&nbsp;&nbsp;键&nbsp;字:</dt>-->
                            <!--<dd> <input type="text" name="keyword_d" id="keyword_d"  class="form-control" placeholder="多个关键字可以以空格分隔"-->
                                    <!--/></dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>搜索范围:</dt>-->
                            <!--<dd>-->
                                <!--<select  id="search_type_d" name="search_type_d">-->
                                    <!--<option value="1" id="full_d">全文</option>-->
                                    <!--<option value="0">仅标题</option>-->
                                <!--</select>-->
                            <!--</dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>招标类型:</dt>-->
                            <!--<dd>-->
                                <!--<input type="radio" checked onclick="full_d(0);" name="tender_type_d" value="0" >招标信息-->
                                <!--<input type="radio" onclick="full_d(1);" name="tender_type_d" value="1">中标信息-->

                            <!--</dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>是否过期:</dt>-->
                            <!--<dd>-->
                                <!--<input type="radio" checked name="isOverdue_d" onclick="isOver(0);"  value="0">全部-->
                                <!--<input type="radio"  name="isOverdue_d" value="1" onclick="isOver(1)">未过期-->
                                <!--<span style="font-size: 12px">（说明：信息为中标，是否过期无用）</span>-->
                            <!--</dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>公&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;司:</dt>-->
                            <!--<dd>-->
                                <!--<input id="search_subscriber_d" type="text" name="search_subscriber_d"  class="form-control" placeholder="招标公司/中标公司"-->
                                       <!--value="${search_subscriber!}">-->
                            <!--</dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;域:</dt>-->
                            <!--<dd>-->
                                <!--<select class="span3" name="location_d" id="location_d" onchange="locations();">-->
                                    <!--<option value="0">省份</option>-->
                                    <!--<#list locations as x>-->
                                        <!--<option value="${x.id}">${x.name}</option>-->
                                    <!--</#list>-->
                                <!--</select>-->

                                <!--<select id="location_d1" name="location_d1" >-->
                                    <!--<option value="0">地区</option>-->

                                <!--</select>-->
                            <!--</dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>金&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;额:</dt>-->
                            <!--<dd>-->
                                <!--<select style="width:150px" id="itemAmount_d" name="itemAmount_d" >-->
                                    <!--<option value="0" >全部</option>-->
                                    <!--<option value="1">20万以下</option>-->
                                    <!--<option value="2">20万到50万</option>-->
                                    <!--<option value="3">50万到100万</option>-->
                                    <!--<option value="4">100万到300万</option>-->
                                    <!--<option value="5">300万到600万</option>-->
                                    <!--<option value="6">600万到1000万</option>-->
                                    <!--<option value="7">1000万以上</option>-->
                                <!--</select>-->
                            <!--</dd>-->
                        <!--</dl>-->
                        <!--<dl>-->
                            <!--<dt>资&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;质:</dt>-->
                            <!--<dd>-->
                                <!--<select  style="width:150px" id="qualification_d" name="qualification_d">-->
                                    <!--<option value="0" >全部</option>-->
                                    <!--<#list qualificationList as x>-->
                                        <!--<option value="${x.id}" >${x.name}</option>-->
                                    <!--</#list>-->
                                <!--</select>-->
                            <!--</dd>-->
                        <!--</dl>-->

                    <!--</div>-->

                    <!--<div class="modal-footer">-->
<!--(说明:当招标类型为中标时，是否过期、地域与资质无法选取！)-->
                        <!--<button type="button" class="btn btn-success" id="xinz" onclick="sub();">新增</button>-->
                        <!--&lt;!&ndash;<button type="button" class="btn btn-danger" onclick="dele();">删除</button>&ndash;&gt;-->
                        <!--<button type="button" class="btn btn-primary" id="xiug" onclick="xiu();">修改</button>-->
                        <!--<button type="button" class="btn btn-default" id="colo" data-dismiss="modal">关闭</button>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->
        <!--</form>-->
    </dd>
</dl>
<dl>

    <dt>
        关&nbsp;键&nbsp;字:
    </dt>
    <dd>
        <input id="appendedInputButtons" type="text" name="search_key" class="form-control" placeholder="多个关键字可以以空格分隔"
               value="${search_key!}"/>
                        <span>
                        搜索范围:&nbsp;
                        <select id="search_type" name="search_type">
                            <option value="0">仅标题</option>
                            <option value="1" id="full">全文</option>
                        </select>
                        </span>
    </dd>
</dl>

<!--<dl>-->
<!--<dt>搜索范围:</dt>-->
<!--<dd>-->
<!--<input type="radio" name="search_type" value="0">仅标题-->
<!--<input type="radio" name="search_type" value="1">全文-->
<!--</dd>-->
<!--</dl>-->

<dl>
    <dt>招标类型:</dt>
    <dd>
        <input type="radio" onclick="full(0);"name="tender_type" value="0">招标信息
        <input type="radio" onclick="full(1);" name="tender_type" value="1">中标信息

    </dd>
</dl>
<dl>
    <dt>是否过期:</dt>
    <dd>
        <input type="radio" name="isOverdue" onclick="isOver(0);" value="0">全部
        <input type="radio" name="isOverdue" onclick="isOver(1);" value="1">未过期
        <span style="font-size: 12px">（说明：信息为中标，是否过期无用）</span>
    </dd>
</dl>
<#if user.istest==1>

    <dl>
        <dt>类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别:</dt>
        <div>                                    <dd id="idust1">

            <select name="idust" style="width:100px"  onchange="change1(this.value,2)">
                <option value="0">全部</option>
                <#list IndustryList as Industrys>
                    <option value="${Industrys.id}">${Industrys.name}</option>
                </#list>
            </select>
            <!--<select name="idust2" style="width: 150px" id="idust2" onclick="change2(this.value,3)">-->

            <!--</select>-->
            <!--<select style="width: 150px" id="idust3" >-->

            <!--</select>-->
        </dd>
        </div>

    </dl>
</#if>
<!--<dl>-->
<!--<dt>排序方式:</dt>-->
<!--<dd>-->
<!--<input type="radio" name="orderby" value="1">时间序-->
<!--<input type="radio" name="orderby" value="0">相关序-->
<!--</dd>-->
<!--</dl>-->
<dl>
    <dt>公&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;司:</dt>
    <dd>
        <input id="appendedInputButtons1" type="text" name="search_subscriber" class="form-control" placeholder="招标公司/中标公司"
               value="${search_subscriber!}">
    </dd>
</dl>
<dl>
    <dt>资&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;质:</dt>
    <dd>
        <select  style="width:150px" id="qualification" name="qualification">
            <option value="0" >全部</option>
            <#list qualificationList as x>
                <option value="${x.id}" >${x.name}</option>
            </#list>
        </select>
    </dd>
</dl>
<dl>
    <dt>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;域:</dt>
    <dd>
        <select class="span3" name="location" id="location" onchange="locations1()">
            <option value="0">省份</option>
            <#list locations as x>
                <option value="${x.code}">${x.name}</option>
            </#list>
        </select>
        <select id="location1" name="location1">
            <option value="0">地区</option>
        </select>
    </dd>
</dl>
<dl>
    <dt>金&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;额:</dt>
    <dd>
        <select style="width:150px" id="itemAmount" name="itemAmount">
            <option value="0" >全部</option>
            <option value="1">20万以下</option>
            <option value="2">20万到50万</option>
            <option value="3">50万到100万</option>
            <option value="4">100万到300万</option>
            <option value="5">300万到600万</option>
            <option value="6">600万到1000万</option>
            <option value="7">1000万以上</option>
        </select>
    </dd>
</dl>



<dl>
    <dt>&nbsp;</dt>
    <dd>
        <div style="float: left">
        <input type="submit" value="搜索" class="form-control"/>
        </div>
        <div style="float: left">
          &nbsp;&nbsp;&nbsp;

        <input type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal1" value="保存此模板"/>

            <div class="modal" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel1">模板保存</h4>
                        </div>
                        <div class="modal-body">
                            <dl>
                                <dt>模板名称:</dt>
                                <dd><input type="text" id="name"  class="form-control" placeholder="模板名称"
                                        /></dd>
                            </dl>
                        </div>
                        <div class="modal-footer">
                            <span id="msg"></span>
                            <button type="button" class="btn btn-primary"  onclick="add_model();">保存</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
       </div>
    </dd>
</dl>
</div>

<div class="col-md-6">
    <h3>推荐信息</h3>
    <hr size=2 style="COLOR:#ff9999;border-style:double;width:490">

    <#list newsPageAnd as x>
        <#if x.status?index_of("[未过期]")!=-1>


            <dl style="width:700px;">
                <#if x.endTime!="">
                    <dt style="width:90px;"><span class="glyphicon glyphicon-asterisk"></span>${x.endTime!}</dt>
                    <dd>
                        <div style="width:400px;"> <a title="${x.title}"  href="${x.url}" target="_blank">

                            <#if x.title_key?length gt 22>
                                ${x.title_key?substring(0,22)}......
                                <#else>
                                    ${x.title_key}
                            </#if>

                        </a></div>
                    </dd>

                    <#else>
                        <dt style="width:90px;"><span class="glyphicon glyphicon-asterisk"></span>无截止日期</dt>
                        <dd><a title="${x.title}" href="${x.url}"  target="_blank">
                            <#if x.title_key?length gt 22>
                                ${x.title_key?substring(0,22)}......
                                <#else>
                                    ${x.title_key}
                            </#if>
                        </a></dd>
                </#if>

            </dl>
        </#if>

    </#list>
    <!--${newsSize!}-->
    <#if newsPageAnd.size() &lt; 1>
        <!--${newsPageAnd.size()}-->

            没有推荐信息！
    </#if>

</div>
</div>

</form>
</div>
<!-- 搜索结束-->
<div class="aw-mod">
    <div class="aw-mod-head">
        <h4>搜索内容</h4>
    </div>
    <!--<div class="aw-mod-body aw-user-work aw-user-setting-layout aw-user-setting-reset-table" style="width: 1020px">-->
    <!--</div>-->
    <div style="width: 1020px;height:30px;">


    </div>
    <div class="aw-user-setting-reset-table">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>#</th>
                <th>项目名称
                    <!--<a href="/search?bian=1&bi=${bi!}&itemAmount=${itemAmount!}&search_type=${search_type!}&search_key=${search_key!}&search_subscriber=${search_subscriber!}&tender_type=${tender_type!}&isOverdue=${isOverdue!}&qualification=${qualification!}&location=${location!}&hiden=${hiden!}"><span id="b1" class="glyphicon glyphicon-chevron-up"></span></a>-->
                    <a onclick="wino(1)"><span id="b1" class="glyphicon glyphicon-chevron-up"></span></a>

                </th>
                <!--<th style="width:95px"><a href="/search?startTime_order=1">招标开始时间</a></th>-->
                <th style="width: 120px">招标截止日期
                    <a onclick="wino(2)"><span id="b2" class="glyphicon glyphicon-chevron-up"></span></a>

                </th>

                <th style="width: 100px">资质
                    <a onclick="wino(3)"><span id="b3" class="glyphicon glyphicon-chevron-up" ></span></a>

                </th>
                <th style="width: 100px">最高限价
                    <a onclick="wino(4)"><span id="b4" class="glyphicon glyphicon-chevron-up"></span></a><br/>
                    (单位：万元)

                </th>
                <th style="width: 120px">招标用户单位
                    <a onclick="wino(5)"><span id="b5" class="glyphicon glyphicon-chevron-up" ></span></a>

                </th>
                <th style="width: 110px">来源
                    <a onclick="wino(6)"><span id="b6" class="glyphicon glyphicon-chevron-up"></span></a>
                </th>
                <th style="width: 40px"></th>
            </tr>
            </thead>
            <tbody >

            <#if newsPage??>
            <#list newsPage.getList() as x>
                <tr>
                    <td>${x_index+1}</td>
                    <td>
                        ${x.status}
                        <a title="${x.title}" href="${x.url}" target="_blank">${x.title_key}</a>
                        <#if time_last_login < x.timelong >
                        <span class="highlight hot">[新]</span>
                        </#if>
                    </td>
                    <!--<td>${x.startTime!}</td>-->
                    <td>${x.endTime!}</td>
                    <td>${x.qualification!}</td>
                    <td>
                        <#if x.item_amount!=0>
                            ${(x.item_amount/10000)?string("#.00")}
                        </#if>
                    </td>
                    <td>${x.subscriber!}</td>
                    <td>
                        ${x.hostName!}
                    </td>
                    <td>
                        <a class="btn btn-sm btn-danger" href="news/detailsPage?id=${x.id}&keyList=${search_key!}&qualification=${qualification}" target="_blank">详情 </a>
                    </td>
                </tr>
            </#list>
            </#if>
            </tbody>
        </table>
        <#include "/home/paginate.html" />
        <#if newsPage??>
        <@paginate currentPage=newsPage.pageNumber totalPage=newsPage.totalPage actionUrl="search?search_key=${search_key_hi!}&search_type=${search_type!}&search_subscriber=${search_subscriber!}&tender_type=${tender_type!}&isOverdue=${isOverdue!}&orderby=${orderby!}&bi=${bi!}&bian=${bian!}&itemAmount=${itemAmount!}&qualification=${qualification!}&location=${location!}&hiden=${hiden!}&kou=1&p=" />
        </#if>
    </div>

</div>



</div>
</div>
<style  type="text/css">
    .hidden{
        display: none;
    }

</style>
<script type="text/javascript" >
var tender_type_d=0;
var isOverdue_d=0;
function dele(){
//    $("#pand").modal("hide");
    var id=$("#hiden").val();
    if(!confirm("是否删除？")){
        return;
    }else {
        $.post(
                "search/deleteModule",
                {id: id},
                function (data) {
                    if (data.msg == 0) {
                        alert("删除成功！");
                        window.location.href = "search";
                    } else if (data.msg == 1) {
                        alert("删除失败！");
                    }
                }, "json"
        );
    }
}
function xiu(){
//    var model1=$("#model1").val();
    var id=$("#hiden").val();
    var name_d=$("#name").val().trim();
    var keyword_d=$("#appendedInputButtons").val();
    var search_type_d=$("#search_type").val();
    var search_subscriber_d=$("#appendedInputButtons1").val();
    var location_d=$("#location1").val();
    if(location_d==0){
        location_d=$("#location").val();
    }
    var itemAmount_d=$("#itemAmount").val();
    var qualification_d=$("#qualification").val();
    if(name_d.length>15){
        alert("模板名称过长,最高不得超过十五个字符！");
    }else if(keyword_d.length>100){
        alert("关键字过长！");
    }else if(search_subscriber_d.length>50){
        alert("公司名称过长！");
    }else if(name_d==null || name_d=="") {
        alert("模板名称不能为空！");
    }else{
        $.post(
                "search/modul_update",
                {id:id,name_d:name_d,keyword_d:keyword_d,search_type_d:search_type_d,tender_type_d:tender_type_d,isOverdue_d:isOverdue_d,
                    search_subscriber_d:search_subscriber_d,location_d:location_d,itemAmount_d:itemAmount_d,qualification_d:qualification_d},
                function(data){
                    if(data.msg==1){
                        alert("修改失败!");
                    }else if(data.msg==0){
                        alert("修改成功!");
                        $("#setting_form").submit();
//                        window.location.href ="search?hiden="+id;
                    }else if(data.msg==2){
                        alert("模板名重复！");
                    }else if(data.msg==3){
                        alert("模板名称过长,最高不得超过十五个字符！");
                    }
                },"json"
        );
    }
}
function insertMo(){
    $("#name_d").prop("disabled", false);
    $("#xinz").removeClass("hidden");
    $("#xiug").addClass("hidden");
    $("#model1").val(0);
    moban(2);
    $('#myModal').modal('show')
}
function updateMo(){
    var id=$("#model").val();
    if(id==0){
        alert("当前模板为无，无法修改");
        $('#myModal').modal('hide')
        return;
    }else {
        $("#name_d").prop("disabled", true);
        moban(1);
        $("#xinz").addClass("hidden");
        $("#xiug").removeClass("hidden");
        $('#myModal').modal('show')
    }
}
function caoz(id){
    $("#hiden").val(id);
    $("#pand").modal('show');
}
function moban(id){
//    if(b==0){
//        var id=$("#model").val();
    var b;
    if(id==-1) {
         b=1;
         id = $("#hiden").val();
    }
    $("#hiden").val(id);
        $.post(
                "search/findById",
                {id:id},
                function(data){
//                    $("#model1").val(id);
                    $("#pand").modal('hide');
                    var module=data.module;
                    $("#appendedInputButtons").val(module.search_key);
//                        $("#appendedInputButtons1").var(module.);
                    $("#search_type").val(module.search_type);
                    $("#qualification").val(module.qualification_id);
                    var tender_type = module.tender_type;
                    if(tender_type==1){
                        $("input[name='tender_type']:eq(1)").click();
                    }else{
                        $("input[name='tender_type']:eq(0)").click();
                    }
                    $("#itemAmount").val(module.item_amount);
                    $("#hiddenId").val(module.id);
                    var isOverdue = module.is_overdue;
                    if(isOverdue==1){
                        $("input[name='isOverdue']:eq(1)").click();
                    }else{
                        $("input[name='isOverdue']:eq(0)").click();
                    }
                    $("#search_type").val(module.search_type);
                    $("#appendedInputButtons1").val(module.search_subscriber);
//                    if(data.location==null){
//                        $("#location").val(0);
//                    }else{
//                        $("#location").val(data.location);
//                    }
//                    alert(data.shi);
                    $("#location").val(data.shen);
                    locations1(data.shi);
                    if(b==1) {
                        $("#setting_form").submit();
                    }
//                    if(data.location!=null) {
//                        if (data.location.level == 1) {
//                            $("#location").val(data.location.id);
//                            $("#location1").val(0);
//                        } else if (data.location.level == 2 || data.location.level == 3) {
//                            $("#location").val(data.location.pid);
//                            locations1(data.location.id);
//                        }
//                    }else{
//                        $("#location").val(0);
//                        $("#location1").val(0);
//                    }
                },"json"


//    else if(b==1){
//
//        var id=$("#model").val();
//        $.post(
//                "search/findById",
//                {id:id},
//                function(data){
//                    var module=data.module;
////                    $("#hiddenId").val(module.id);
//                    $("#name_d").val(module.search_module_name);
////                        $("#search_type_d").val(module.search_type);
//                    $("#keyword_d").val(module.search_key);
//                    $("#qualification_d").val(module.qualification_id);
//                    var tender_type = module.tender_type;
//                    if(tender_type==1){
//                        $("input[name='tender_type_d']:eq(1)").click();
//                    }else{
//                        $("input[name='tender_type_d']:eq(0)").click();
//                    }
//                    $("#itemAmount_d").val(module.item_amount);
//
//                    var isOverdue = module.is_overdue;
//                    if(isOverdue==1){
//                        $("input[name='isOverdue_d']:eq(1)").click();
//                    }else{
//                        $("input[name='isOverdue_d']:eq(0)").click();
//                    }
//                    $("#search_type_d").val(module.search_type);
//                    $("#search_subscriber_d").val(module.search_subscriber);
////                    if(data.location==null){
////                        $("#location").val(0);
////                    }else{
////                        $("#location_d").val(data.location);
////                    }
//                    if(data.location!=null) {
//                        if (data.location.level == 1) {
//                            $("#location_d").val(data.location.id);
//                            locations();
//                        } else if (data.location.level == 2 || data.location.level == 3) {
//                            $("#location_d").val(data.location.pid);
//                            var id=data.location.id;
//                            locations(id);
//                        }
//                    }else{
//                        $("#location_d").val(0);
//                        $("#location_d1").val(0);
//                    }
//                },"json"
        );
}
//    }else if(b==2){
//
//        var id=$("#model1").val();
//        $.post(
//                "search/findById",
//                {id:id},
//                function(data){
//                    var module=data.module;
////                    $("#hiddenId").val(module.id);
//                    $("#name_d").val(module.search_module_name);
////                        $("#search_type_d").val(module.search_type);
//                    $("#keyword_d").val(module.search_key);
//                    $("#qualification_d").val(module.qualification_id);
//                    var tender_type = module.tender_type;
//                    if(tender_type==1){
//                        $("input[name='tender_type_d']:eq(1)").click();
//                    }else{
//                        $("input[name='tender_type_d']:eq(0)").click();
//                    }
//                    $("#itemAmount_d").val(module.item_amount);
//
//                    var isOverdue = module.is_overdue;
//                    if(isOverdue==1){
//                        $("input[name='isOverdue_d']:eq(1)").click();
//                    }else{
//                        $("input[name='isOverdue_d']:eq(0)").click();
//                    }
//                    $("#search_type_d").val(module.search_type);
//                    $("#search_subscriber_d").val(module.search_subscriber);
////                    if(data.location==null){
////                        $("#location").val(0);
////                    }else{
////                        $("#location_d").val(data.location);
////                    }
//                    if(data.location!=null) {
//                        if (data.location.level == 1) {
//                            $("#location_d").val(data.location.id);
//                            locations();
//                        } else if (data.location.level == 2 || data.location.level == 3) {
//                            $("#location_d").val(data.location.pid);
//                            var id=data.location.id;
//                            locations(id);
//                        }
//                    }else{
//                        $("#location_d").val(0);
//                        $("#location_d1").val(0);
//                    }
//                },"json"
//        );
//    }

function add_model(){
    var name_d=$("#name").val().trim();
    var keyword_d=$("#appendedInputButtons").val();
    var search_type_d=$("#search_type").val();
    var search_subscriber_d=$("#appendedInputButtons1").val();
    var location_d=$("#location1").val();
    if(location_d==0) {
        location_d = $("#location").val();
    }
    var itemAmount_d=$("#itemAmount").val();
    var qualification_d=$("#qualification").val();
    if(name_d.length>15) {
        alert("模板名称过长,最高不得超过十五个字符！");
    }else if(name_d==null || name_d=="") {
        alert("模板名称不能为空！");
    }else {
        $.post(
                "search/modul_add",
                {name_d: name_d, keyword_d: keyword_d, search_type_d: search_type_d, tender_type_d: tender_type_d, isOverdue_d: isOverdue_d,
                    search_subscriber_d: search_subscriber_d, location_d: location_d, itemAmount_d: itemAmount_d, qualification_d: qualification_d},
                function (data) {
                    if (data.msg == 1) {
                        if(confirm("模板名重复，是否需要修改?")) {
                          $("#myModal1").modal("hide");
                            xiu();
                        }
                    } else if (data.msg == 0) {
                        alert("添加成功!");
                        $("#hiden").val(data.id1);
                        $("#setting_form").submit();
//                        window.location.href ="search?hiden="+data.id1;
//                        $("#model").val(data.id1);
                    }else if(data.msg==2){
                        alert("未知错误!");
                    }else if(data.msg==3){
                        alert("模板名称过长,最高不得超过十五个字符！");
                    }
                }, "json"
        );

    }
}
function sub(){
    var name_d=$("#name_d").val().trim();
    var keyword_d=$("#keyword_d").val();
    var search_type_d=$("#search_type_d").val();
    var search_subscriber_d=$("#search_subscriber_d").val();
    var location_d=$("#location_d1").val();
    if(location_d==0) {
        location_d = $("#location_d").val();
    }
    var itemAmount_d=$("#itemAmount_d").val();
    var qualification_d=$("#qualification_d").val();
    if(name_d.length>15) {
        alert("模板名称过长,最高不得超过十五个字符！");
    }else if(name_d==null || name_d=="") {
        alert("模板名称不能为空！");
    }else {
        $.post(
                "search/modul_add",
                {name_d: name_d, keyword_d: keyword_d, search_type_d: search_type_d, tender_type_d: tender_type_d, isOverdue_d: isOverdue_d,
                    search_subscriber_d: search_subscriber_d, location_d: location_d, itemAmount_d: itemAmount_d, qualification_d: qualification_d},
                function (data) {
                    if (data.msg == 1) {
                        alert("模板名重复!");
                    } else if (data.msg == 0) {
                        alert("添加成功!");
                        window.location.href ="search?model="+data.id1;
                        $("#model").val(data.id1);
                    }else if(data.msg==2){
                        alert("未知错误!");
                    }else if(data.msg==3){
                        alert("模板名称过长,最高不得超过十五个字符！");
                    }
                }, "json"
        );

    }

}

function locations(id){

    $("#location_d1").html("");
    var location_id=$("#location_d").val();

//        $("#location_id").append("<select name='location_id1' style='width: 100px' id='location_id1'></select>");
    document.getElementById("location_d1").options[0] = new Option("地区",0);
    if(location_id!=0) {
        $.post(
                "user_district/findDis",
                {location_id: location_id},
                function (data) {
                    var data1 = data.list;
                    for (var i = 0; i < data1.length; i++) {
                        document.getElementById("location_d1").options[i+1] = new Option(data1[i].name, data1[i].id);
                    }
//                    alert(id);
                    if(id>0 ) {
                        $("#location_d1").val(id);
                    }
                }, "json"
        );
    }
}
function locations1(id){
    $("#location1").html("");
    var location_id=$("#location").val();
    document.getElementById("location1").options[0] = new Option("地区",0);
//        $("#location_id").append("<select name='location_id1' style='width: 100px' id='location_id1'></select>");
    if(location_id!=0) {
        $.post(
                "user_district/findDis",
                {location_id: location_id},
                function (data) {
                    var data1 = data.list;
                    for (var i = 0; i < data1.length; i++) {
                        document.getElementById("location1").options[i+1] = new Option(data1[i].name, data1[i].code);
                    }
                    if(id>0 ) {
                        $("#location1").val(id);
                    }
                }, "json"
        );
    }
}


function full(a){
    tender_type_d=a;
//                 alert("123");
        if(a==0){
            $("[name=isOverdue]").prop("disabled",false);
            $("#full").prop("disabled", false);
            $("#qualification").prop("disabled", false);
            $("#location").prop("disabled", false);
            $("#location1").prop("disabled", false);
        }else{
            $("[name=isOverdue]").prop("disabled",true);
            $("#search_type").val(0);
            $("#full").prop("disabled", true);
            $("#qualification").prop("disabled", true);
            $("#location").prop("disabled", true);
            $("#location1").prop("disabled", true);
            $("#qualification").val(0);
            $("#location").val(0);
            $("#location1").val(0);
        }



}
function isOver(a){
    isOverdue_d=a;
}
function full_d(a){
    tender_type_d=a;
    if(a==0){
        $("[name=isOverdue_d]").prop("disabled",false);
        $("#full_d").prop("disabled", false);

        $("#qualification_d").prop("disabled", false);
        $("#location_d").prop("disabled", false);
        $("#location_d1").prop("disabled", false);
    }else{
        $("[name=isOverdue_d]").prop("disabled",true)
        $("#search_type_d").val(0);
        $("#full_d").prop("disabled", true);
        $("#qualification_d").prop("disabled", true);
        $("#location_d").prop("disabled", true);
        $("#location_d1").prop("disabled", true);
        $("#qualification_d").val(0);
        $("#location_d").val(0);
        $("#location_d1").val(0);

    }
}
function bian(b) {
    window.location.href="/search?bian=1&bi="+'${bi!}';
}

function change1(va,b){
//                $("#idust2").removeClass("hidden");
//                $("#idust2").html("");
    $("#idust3").remove();
    $("#idust2").remove();
//                $("#idust1").append("<h1>213</h1>");
    $("#idust1").append("<select name='idust2' style='width: 100px' id='idust2' onclick='change2(this.value,3)'></select>");

    $.post(

            "/search/IndustryListAjax",{idust:va,level:b},
            function(data) {

                var data1= data.industryList2;
                for(var i=0;i<data1.length;i++){
                    document.getElementById("idust2").options[i] = new Option(data1[i].name,data1[i].id);
                }

            },"json"
    );
}



function change2(va,b){
    $("#idust3").remove();
    $("#idust1").append("<select style='width: 100px' id='idust3' ></select>")
    $.post(
            "/search/IndustryListAjax", {idust: va, level: b},
            function (data) {

                var data1 = data.industryList2;

                for (var i = 0; i < data1.length; i++) {
//                                var a=data1[i].name
//                                 $("#idust3").append("<optgroup label= a ></optgroup>");
                    document.getElementById("idust3").options[i] = new Option(data1[i].name, data1[i].id);
                }

            }, "json"
    );
}

$(function(){
//        alert('${search_key!}');
    var id1=$("#hiden").val();
//    $("#hiden").val(id1);
    if(id1 !=0){
        moban(id1);
    }

    var b='${bi!}';
    if(b==1){
        $("#b1").removeClass("glyphicon glyphicon-chevron-up");
        $("#b1").addClass("glyphicon glyphicon-chevron-down");
    }else{
        $("#b1").removeClass("glyphicon glyphicon-chevron-down");
        $("#b1").addClass("glyphicon glyphicon-chevron-up");
    }

    if(b==2){
        $("#b2").removeClass("glyphicon glyphicon-chevron-up");
        $("#b2").addClass("glyphicon glyphicon-chevron-down");
    }else{
        $("#b2").removeClass("glyphicon glyphicon-chevron-down");
        $("#b2").addClass("glyphicon glyphicon-chevron-up");
    }
    if(b==3){
        $("#b3").removeClass("glyphicon glyphicon-chevron-up");
        $("#b3").addClass("glyphicon glyphicon-chevron-down");
    }else{
        $("#b3").removeClass("glyphicon glyphicon-chevron-down");
        $("#b3").addClass("glyphicon glyphicon-chevron-up");
    }
    if(b==4){
        $("#b4").removeClass("glyphicon glyphicon-chevron-up");
        $("#b4").addClass("glyphicon glyphicon-chevron-down");
    }else{
        $("#b4").removeClass("glyphicon glyphicon-chevron-down");
        $("#b4").addClass("glyphicon glyphicon-chevron-up");
    }
    if(b==5){
        $("#b5").removeClass("glyphicon glyphicon-chevron-up");
        $("#b5").addClass("glyphicon glyphicon-chevron-down");
    }else{
        $("#b5").removeClass("glyphicon glyphicon-chevron-down");
        $("#b5").addClass("glyphicon glyphicon-chevron-up");
    }
    if(b==6){
        $("#b6").removeClass("glyphicon glyphicon-chevron-up");
        $("#b6").addClass("glyphicon glyphicon-chevron-down");
    }else{
        $("#b6").removeClass("glyphicon glyphicon-chevron-down");
        $("#b6").addClass("glyphicon glyphicon-chevron-up");
    }


//                $("#idust2").addClass("hidden");
//                $("#idust3").addClass("hidden");
//        var search_type = '${search_type}';
    $("#search_type").val('${search_type}');

    $("#qualification").val('${qualification}');
//        alert('${qualification}');
//        if(search_type==1){
//            $("input[name='search_type']:eq(1)").click();
//        }else{
//            $("input[name='search_type']:eq(0)").click();
//        }
    var tender_type = '${tender_type}';
    if(tender_type==1){
        $("input[name='tender_type']:eq(1)").click();
    }else{
        $("input[name='tender_type']:eq(0)").click();
    }


//            alert('${shi!}');
            $("#location").val('${shen!}');
            locations1('${shi!}');
//            $("#location1").val(110101);

//    var loc='${loca!}';
//    if(loc!=null ||loc!='' ) {
//        if ( '${loca_level!}' == 1) {
//            $("#location").val('${loca_id!}');
//            document.getElementById("location1").options[0] = new Option("地区", 0);
//            $("#location1").val(0);
//        } else if ('${loca_level!}'  == 2 ||'${loca_level!}'  == 3) {
//            $("#location").val('${loca_pid!}');
//            locations1();
//            $("#location1").val('${loca_id!}');
//        }
//    }else{
//        $("#location").val(0);
//        document.getElementById("location1").options[0] = new Option("地区", 0);
//        $("#location1").val(0);
//    }

    $("#itemAmount").val('${itemAmount}');

    var isOverdue = '${isOverdue}';
    if(isOverdue==1){
        $("input[name='isOverdue']:eq(1)").click();
    }else{
        $("input[name='isOverdue']:eq(0)").click();
    }

//                var orderby = '${orderby}';
//                if(orderby==1){
//                    $("input[name='orderby']:eq(0)").click();
//                }else{
//                    $("input[name='orderby']:eq(1)").click();
//                }


    $("#search_type").val('${search_type}');
});
function wino(a){
    window.location.href="/search?bian="+a+"&bi=${bi!}&itemAmount=${itemAmount!}&search_type=${search_type!}&search_key=${search_key_hi!}&search_subscriber=${search_subscriber!}&tender_type=${tender_type!}&isOverdue=${isOverdue!}&qualification=${qualification!}&location=${location!}&hiden=${hiden!}";
}


//替换加号
function FixJqText(str) {
    var tempstr = str.replace(/\+/g, "%2B");
    return tempstr;
}

function myrefresh()
{
    window.location.reload();
}
</script>

</div>
<#include "../global/footer.html">